Caption = "2. Close the MDI child window, press the MDI parent image button again and select the popup menu entry 'Show Modal Child Window'. A modal child window similar to the previously opened MDI child window comes up. But if you press its image button which should pop up the same menu as in the MDI child window, no popup menu appears. This happens because of the non-reentrancy of the code of the container window."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00FF0000&
Height = 840
Left = 585
TabIndex = 4
Top = 2130
Width = 8205
End
Begin Label Label2
BackStyle = 0 'Transparent
Caption = "1. Click on the 'Show MDI Child Window' entry of the popup menu. A MDI child window will open hat also contains an image button with a popup menu. This popup menu is also defined on the hidden container form. If you click on the image button, the popup menu appears. So far, so good."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00FF0000&
Height = 675
Left = 585
TabIndex = 3
Top = 1395
Width = 8205
End
Begin Label Label1
BackStyle = 0 'Transparent
Caption = "The 'MouseDown' event of this image button pops up a menu that is defined on a hidden form (frmMenuContainer)."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00FF0000&
Height = 360
Left = 585
TabIndex = 2
Top = 1065
Width = 8205
End
Begin Label lblMenuClick
BackColor = &H000000FF&
ForeColor = &H000000FF&
Height = 225
Left = 8940
TabIndex = 1
Top = 810
Visible = 0 'False
Width = 285
End
Begin Image imgButtonUp
Height = 330
Left = 8895
Picture = MDIPAREN.FRX:0000
Top = 45
Visible = 0 'False
Width = 360
End
Begin Image imgButtonDown
Height = 330
Left = 8895
Picture = MDIPAREN.FRX:0182
Top = 390
Visible = 0 'False
Width = 360
End
Begin Image imgPopUp
Height = 330
Left = 4380
Top = 135
Width = 360
End
End
End
Option Explicit
Sub HandleMyPopUp (P_nIndex As Integer)
' This sub handles the clicks on the menu entries of the
' MDI parent popup menu received by lblMenuClick from frmMenuContainer
Select Case P_nIndex
Case 0:
' Show MDI child window
frmMDIChild.Show
Case 1:
' Show modal child window
frmModalChild.Show 1
Case 3:
' Exit
End
End Select
End Sub
Sub imgPopUp_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show 'button down' image
imgPopUp = imgButtonDown
' Pop up the MDI parent menu defined in frmMenuContainer
PopupMenu frmMenuContainer.mnuPopUpMDIParent, 0
' Show 'button up' image
imgPopUp = imgButtonUp
End Sub
Sub lblMenuClick_Change ()
' The 'Change' event of this label is triggered when a click on
' a menu entry in frmMenuContainer sets the label caption with the
' related menu entry index
' Handle the menu click if an index is available
If lblMenuClick <> "" Then HandleMyPopUp Val(lblMenuClick)
' Reset the label for new menu entry clicks
lblMenuClick = ""
End Sub
Sub MDIForm_Load ()
' Startup: Load the hidden menu container form
Load frmMenuContainer
' Show 'button up' image initially
imgPopUp = imgButtonUp
End Sub
Sub MDIForm_QueryUnload (Cancel As Integer, UnloadMode As Integer)